package com.hexb.smh.utils;

import com.hexb.smh.entity.Account;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.UnauthenticatedException;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.DefaultSessionContext;
import org.apache.shiro.session.mgt.DefaultSessionKey;
import org.apache.shiro.subject.Subject;

import java.util.Collection;

/**
 * @author : hexb
 */
@Slf4j
public class AccountHelper {

    static public Account getAccount() {
        Subject subject = SecurityUtils.getSubject();
        Object principal = subject.getPrincipal();
        if (null == principal) {
            log.warn("====> Get Login User Failed!");
            throw new UnauthenticatedException();
        }
        return (Account) principal;
    }

}
